/* ServiceColl.java
 * 
 * A collection of all service types from all providers 
 * 
 * Greg Warner
 * Derek Dupuis
 * Michael Dixey
 * Alex Schwartz
 */

import java.util.*;

public class ServiceColl extends TreeMap< String, Service >
    implements CollectionIF< Service >
{
    public ServiceColl()
    {
        super();
    }
    
    //-----------------------------CollectionIF methods-----------------
    
    // adds a provider to the list
    public boolean add( Service s )
    {
        if ( ! this.containsKey( s.type( ) ) )
        {            
            this.put( s.type(), s );
            return true;
        }
        else
            return false;
    }
    
    // returns true if provider is in the list already
    public boolean find( String s )
    {
        return this.containsKey( s );
    }
    
    public Service get( String s )
    {
        return super.get( s );
    }
    
    // returns a string representation of the provider
    public String toString()
    {
        String s = "SERVICES:\n";
        
        Set    z = this.keySet( );
        
        
        Iterator iter = z.iterator();
        
        while( iter.hasNext() )
            s = s + this.get( iter.next() ).toString() + '\n';
        
        return s;
    }
}